'''
Description: 
Author: gn
Date: 2024-06-08 15:15:43
LastEditors: gn
LastEditTime: 2024-06-08 15:58:19
'''
import pygame
from pygame.sprite import Sprite

class Alien(Sprite): 
  
  def __init__(self, ai_game):
    
    '''初始化外星人设置位置并加载图像'''
    super().__init__()
    self.screen = ai_game.screen
    
    # 加载外星人并设置其rect属性
    origin_image = pygame.image.load('alien_invasion/images/emojiAlien.png')
    
    # 在python中// 是整除 而 / 是浮点除
    resize_image_width = origin_image.get_width() / 6
    resize_image_height = origin_image.get_height() / 6
    self.image = pygame.transform.scale(origin_image, (resize_image_width, resize_image_height))
    self.rect = self.image.get_rect()
    self.rect.x = self.rect.width
    self.rect.y = self.rect.height
    
    # 存储外星人位置
    self.x = float(self.rect.x)